package hbt;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import bean.*;


public class HibernateUtil {

	private static final SessionFactory sessionFactory;
	static
	{
		try
		{
			AnnotationConfiguration conf = new AnnotationConfiguration();
			conf.addAnnotatedClass(Articulo.class);
			conf.addAnnotatedClass(Cliente.class);
			conf.addAnnotatedClass(Fabricante.class);
			conf.addAnnotatedClass(Importado.class);
			conf.addAnnotatedClass(Importador.class);
			conf.addAnnotatedClass(ItemPedido.class);
			conf.addAnnotatedClass(Nacional.class);
			conf.addAnnotatedClass(Pedido.class);
			sessionFactory = conf.buildSessionFactory();
			
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
			throw new ExceptionInInitializerError(ex);
		}
	 
	}
	
	public static SessionFactory getSessionFactory()
	{
		return sessionFactory;
	}
}
